<?php
namespace App\Logic\SalesReport;

class PaymentReportWork
{
    public static function accounting($model,$date)
    {
        if('null' == $date){
            $date = date('Y-m-01',strtotime('midnight first day of -1 month'));
        }
        ini_set('memory_limit', '200M');
        set_time_limit(0);
        $class = self::$_model[$model];
        $class::exePayment($date);
    }

    private static $_model = ['detail' => PaymentDetail::class,
        'common' => PaymentDetailCommon::class,
        'ling' => PaymentDetailLing::class,
        'common-up' => PaymentDetailCommonUp::class,
        'classify-id' => PaymentForClassifyId::class,
        'classify' => PaymentClassify::class,
        'area' => PaymentArea::class,
        'country' => PaymentCountry::class,
        'seller' => PaymentSeller::class,
        'none-classify' => PaymentNoneClassify::class,
        'none' => PaymentNone::class,
    ];

    public static function accountingForJP($func,$date)
    {
        ini_set('memory_limit', '200M');
        set_time_limit(0);
        if('null' == $date){
            $date = date('Y-m-01',strtotime('midnight first day of -1 month'));
        }
        $lastYearDate = date('Y-m-01',strtotime('-1 year',strtotime($date)));
        PaymentDetailForJP::{$func}($date,$lastYearDate);
    }
}
